#ifndef __WIFI_X_H__
#define __WIFI_X_H__

#include <string.h>
#include <sys/param.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_wifi.h"
#include "esp_event.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "esp_netif.h"
#include "protocol_examples_common.h"

#include "lwip/err.h"
#include "lwip/sockets.h"
#include "lwip/sys.h"
#include <lwip/netdb.h>
#include "addr_from_stdin.h"

// #define START_REC_ON_POWERON 1

/*
if defined: use tcp
if not defined: use udp
*/
#define USE_TCP_UDP 1 

#define use_xinao_net 1
// #define use_huawei_net 1
// #define use_phone_net 1

//  ------------------------
#ifdef use_xinao_net
#define SSID_STRING "Xiaomi_E752"
#define PW_STRING "seky2020"
// #define IP_STRING "192.168.0.206"
// #define IP_STRING "192.168.0.221"
#define IP_STRING "192.168.0.24"
#define PORT_STRING "6002"
#endif

#ifdef use_huawei_net
#define SSID_STRING "HUAWEI-1GRS13"
#define PW_STRING "01234567"
#define IP_STRING "192.168.3.15"
#define PORT_STRING "6002"
#endif

#ifdef use_phone_net
#define SSID_STRING "10.42.31.246"
#define PW_STRING "12341234"
#define IP_STRING "192.168.43.9"
#define PORT_STRING "6002"
#endif

extern char gl_ssid_str[32];
extern char gl_pw_str[64];
extern char gl_ip_str[16];
extern char gl_port_str[8];

//  - -----------------------


typedef enum {
    WIFI_DISCONNECTED,
    WIFI_CONNECTED_NO_IP,
    WIFI_CONNECTED_WITH_IP
} wifi_connection_status_t;

typedef enum {
    WIFI_OK,
    WIFI_BAD
} wifi_status_x_t;


void wifi_x_init(void);
// void wifi_recv_x(char * p_char,size_t len);
int wifi_recv_x(char *p_char, size_t char_len);

int wifi_send_x(const char *p_char, size_t char_len);
void get_mac_str(char* p);

// int wifi_send_x_test(void);
// void wifi_waitfor_connection(void);
// wifi_connection_status_t get_wifi_connection_status(void);
wifi_status_x_t get_wifi_status(void);


#endif